import org.korifey.ffalg.NumberTheory;


public class Problem4 {
	public static void main(String[] args) {
		System.out.println(solve());
	}
	
	private static boolean isPalyndrome(int x) {
		String s = Integer.toString(x);
		for (int i=0; i<s.length()/2; i++) {
			if (s.charAt(i) != s.charAt(s.length()-1-i)) {
				return false;
			}
		}
		return true;
	}
	
	public static long solve() {
		int n = 1000;		
		
		int res = 0;
		for (int i=n/10; i<n; i++) {
			for (int j=i; j<n; j++) {
				int p = i*j;
				if (isPalyndrome(p) && p>res) {
					res = p;
				}
			}			
		}
		return res;
	}
}
